﻿using BLWCMS.Core.Business;
using BLWCMS.Core.IBusiness;
using Nancy;
using Nancy.Bootstrapper;
using Nancy.Conventions;
using Nancy.Session;
using Nancy.TinyIoc;

namespace BLWCMS.Web
{
    public class Bootstrapper : DefaultNancyBootstrapper
    {
        protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
        {
            base.ConfigureRequestContainer(container, context);
            container.Register<IAdminBusiness, AdminBusiness>();
            container.Register<ILoginBusiness, LoginBusiness>();
            container.Register<IWeixinConfigBusiness, WeixinConfigBusiness>();
            container.Register<IMaterialBusiness, MaterialBusiness>();
        }

        protected override void ConfigureConventions(NancyConventions nancyConventions)
        {
            base.ConfigureConventions(nancyConventions);
            nancyConventions.StaticContentsConventions.Add
            (StaticContentConventionBuilder.AddDirectory("Include", "/Include"));
        }

        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            CookieBasedSessions.Enable(pipelines);
        }
    }
}